package com.jt.mapper;

import com.jt.pojo.ItemCat;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ItemCatMapper {

    List<ItemCat> findItemCatList(Integer level);

//    @Select("select * from item_cat")
////    List<ItemCat>findItemCatList();

    @Select("select * from item_cat")
    List<ItemCat> findItemCatAll();


    void saveItemCat(ItemCat itemCat);

    @Update("update item_cat set status=#{status},updated=#{updated} where id=#{id}")
    void updateStatus(ItemCat itemCat);

    @Update("update item_cat set name=#{name},updated=#{updated} where id=#{id}")
    void updateItemCat(ItemCat itemCat);

    @Delete("delete from item_cat where id=#{id}")
    void deleteItemCatById(Integer id);

    @Delete("delete from item_cat where id=#{id} or parent_id=#{id}")
    void deleteItemCat2(Integer id);

    @Delete("delete from item_cat where id=#{id} or parent_id=#{id} or parent_id in (select id from item_cat where parent_id=#{id})")
    void deleteItemCat1(ItemCat itemCat);
}
